<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Quotes an ODBC connection string value</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.odbc-connection-string-is-quoted.html">« odbc_connection_string_is_quoted</a></li>
      <li style="float: right;"><a href="function.odbc-connection-string-should-quote.html">odbc_connection_string_should_quote »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.uodbc.html">ODBC 函数</a></li>
    <li>Quotes an ODBC connection string value</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.odbc-connection-string-quote" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">odbc_connection_string_quote</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.2.0)</p><p class="refpurpose"><span class="refname">odbc_connection_string_quote</span> &mdash; <span class="dc-title">Quotes an ODBC connection string value</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.odbc-connection-string-quote-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>odbc_connection_string_quote</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>): <span class="type">string</span></div>

  <p class="para rdfs-comment">
   Quotes a value for a connection string, according to ODBC rules.
   That is, it will be surrounded by quotes, and any ending curly
   braces will be escaped. This should be done for any connection
   string values that come from user input. Not doing so can lead
   to issues with parsing the connection string, or values being
   injected into the connection string.
  </p>
  <p class="para">
   Note that this function does not check if the string is already
   quoted, nor if the string needs quoting. For that, call
   <span class="function"><a href="function.odbc-connection-string-is-quoted.html" class="function">odbc_connection_string_is_quoted()</a></span> and
   <span class="function"><a href="function.odbc-connection-string-should-quote.html" class="function">odbc_connection_string_should_quote()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.odbc-connection-string-quote-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">str</code></dt>

    <dd>

     <p class="para">
      The unquoted string.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.odbc-connection-string-quote-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   A quoted string, surrounded by curly braces, and properly escaped.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.odbc-connection-string-quote-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="odbc-connection-string-quote.example.basic">
   <p><strong>示例 #1 <span class="function"><strong>odbc_connection_string_quote()</strong></span> example</strong></p>
   <div class="example-contents"><p>
    This example quotes a string, then puts it in a connection string.
    Note that the string is quoted, and the ending quote character in
    the middle of the string has been escaped.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$value&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">odbc_connection_string_quote</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo}bar"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$connection_string&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"DSN=PHP;UserValue=</span><span style="color: #0000BB">$value</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$connection_string</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
DSN=PHP;UserValue={foo}}bar}
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.odbc-connection-string-quote-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.odbc-connection-string-is-quoted.html" class="function" rel="rdfs-seeAlso">odbc_connection_string_is_quoted()</a> - Determines if an ODBC connection string value is quoted</span></li>
    <li class="member"><span class="function"><a href="function.odbc-connection-string-should-quote.html" class="function" rel="rdfs-seeAlso">odbc_connection_string_should_quote()</a> - Determines if an ODBC connection string value should be quoted</span></li>
   </ul>
  </p>
 </div>



</div></div></div></body></html>